﻿@model Upload2.Models.Up

@{
  ViewBag.Title = "Edit";
}

<h2>Edit</h2>


@using (Html.BeginForm())
{
  @Html.AntiForgeryToken()

  <div class="form-horizontal">
    <h4>Up</h4>
    <hr />
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    @Html.HiddenFor(model => model.Id)

    <div class="form-group">
      @Html.LabelFor(model => model.Title, htmlAttributes: new { @class = "control-label col-md-2" })
      <div class="col-md-10">
        @Html.EditorFor(model => model.Title, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model => model.Title, "", new { @class = "text-danger" })
      </div>
    </div>

    @*<div class="form-group">
          @Html.LabelFor(model => model.AttachmentPaths, htmlAttributes: new { @class = "control-label col-md-2" })
          <div class="col-md-10">
              @Html.EditorFor(model => model.AttachmentPaths, new { htmlAttributes = new { @class = "form-control" } })
              @Html.ValidationMessageFor(model => model.AttachmentPaths, "", new { @class = "text-danger" })
          </div>
      </div>*@

    <div class="form-group">
      <label class="control-label col-md-2">图片附件</label>
      <div class="col-md-10">
      </div>
      <div class="row">
        <div class="col-md-offset-2">
          <ul class="col-md-offset-2 list-unstyled ul1">
            <!--上传的图片显示位置-->
            <li>
              <div style="width:60px;height:60px;overflow:hidden">
                <a href="javascript:void(0);" class="aInput pull-right" style="background-color:#eee;">
                  +<input type="file" id="file1" name="file1" accept="image/*" />
                </a>
              </div>
            </li>
            @if (Model.AttachmentPaths != null)
            {
              foreach (var item in Model.AttachmentPaths.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
              {
                if (item.EndsWith(".bmp") || item.EndsWith(".gif") || item.EndsWith(".jpeg") || item.EndsWith(".jpg") || item.EndsWith(".png") || item.EndsWith(".ico"))
                {
                  <li>
                    <div style="width:60px;height:60px;overflow:hidden">
                      <img src="/Uploadfiles/@item" class="upimg" style="width:60px;height:60px;" />
                      <div class="cornerClose" data-ng-src="@item" onclick="remove(this)">&nbsp;&nbsp;&times;</div>
                    </div>
                  </li>
                }
              }
            }


          </ul>
          @Html.HiddenFor(model => model.AttachmentPaths)
        </div>
      </div>
    </div>

    <div class="form-group">
      <div class="row" style="margin:5px 15px;">
        <ul class="col-md-offset-2 list-group ul2">
          <!--上传的文件显示位置-->
          @if (Model.AttachmentPaths != null)
          {
            foreach (var item in Model.AttachmentPaths.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
            {
              if (!item.EndsWith(".bmp") && !item.EndsWith(".gif") && !item.EndsWith(".jpeg") && !item.EndsWith(".jpg") && !item.EndsWith(".png") && !item.EndsWith(".ico"))
              {
                <li class="list-group-item">
                  <a href="/UploadFiles/@item" download="@item.Substring(37)"><span class='glyphicon glyphicon-paperclip'></span><span class="ul2Text">@item.Substring(37)</span></a>
                  <span>
                    <button type="button" class="close" aria-label="Close" data-ng-src="@item" onclick="remove(this)"><span aria-hidden="true">&times;</span></button>
                  </span>
                </li>
              }
            }
          }
        </ul>
      </div>
    </div>




    <div class="form-group">
      <div class="col-md-offset-2 col-md-10">
        <input type="submit" value="Save" class="btn btn-default" />
      </div>
    </div>
  </div>
}

<div>
  @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
  @Scripts.Render("~/bundles/jqueryval")
  <script src="~/Scripts/upload2.js"></script>

}
